"""Pytest配置文件，包含所有测试用例的公共 fixture"""

import pytest
from PyQt5.QtWidgets import QApplication
from main import 儿歌播放器

@pytest.fixture(scope="session")
def qt_app():
    """创建Qt应用程序实例"""
    app = QApplication([])
    yield app
    app.quit()

@pytest.fixture()
def player_window(qt_app):
    """创建播放器窗口实例"""
    window = 儿歌播放器()
    window.show()
    yield window
    window.close()

@pytest.fixture()
def temp_media(tmpdir):
    """创建临时媒体文件用于测试"""
    media_file = tmpdir.join("test.mp3")
    media_file.write_binary(b'fake_audio_data')
    return str(media_file)